#pragma strict
/*

var target : GameObject; //destination
var liftSpeed : float = 10; //speed (it will complete the motion in 1/speed seconds)
private var moving : boolean = false; //flag
private var weight : float = 0; //amount moved
private var startPosition : Vector3; //Where we start;
 
function Update () {
    if(target) {
        if(Input.GetButtonDown("Jump")) { //just pressed Jump
            startPosition = transform.position; //Set the start
            moving = true; //set flag
        }
        if(transform.position != target.transform.position) moving = false; //reset flag
        if(moving){ //check flag
            weight += Time.deltaTime * liftSpeed; //amount
            transform.position = Vector3.Lerp(startPosition, target.transform.position, weight);
        }
    }
}
*/

/*
    var minimum = -2;
    var maximum = -1.4;
    var loop;
    
    function start(){
    loop = true;

    }
    function Update () {
    if(loop){
     transform.position = Vector3(.6f, Mathf.Lerp(maximum, minimum, Time.time), 8.6);
		}
    
            if(transform.position.y == -2){
            	loop = false;
               Debug.Log("hittop");
               if(!loop){
                transform.position = Vector3(.6f, Mathf.Lerp(minimum, maximum, Time.time), 8.6);
                loop = true;
                }
            }
          
    }
    */
    
    var pointB : Vector3;
 
function Start () {
    var pointA = transform.position;
    while (true) {
        yield MoveObject(transform, pointA, pointB, 1.0);
        yield MoveObject(transform, pointB, pointA, 1.0);
    }
}
 
function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float) {
    var i = 0.0;
    var rate = 1.0/time;
    while (i < 1.0) {
        i += Time.deltaTime * rate;
        thisTransform.position = Vector3.Lerp(startPos, endPos, i);
        yield; 
    }
}